package cn.tedu.springbootdemo.tedu;

import ch.qos.logback.core.net.SyslogOutputStream;
import com.alibaba.druid.pool.DruidDataSource;

import java.sql.Connection;
import java.sql.SQLException;

public class DBUtils {
    private static DruidDataSource dds;
    static {
        //创建连接池对象
        dds = new DruidDataSource();
        dds.setUrl("jdbc:mysql://localhost:3306/empdb?" +
                        "characterEncoding=utf8" +
                        "&serverTimezone=Asia/Shanghai&useSSl=false");

        dds.setUsername("root");
        dds.setPassword("111112");
        dds.setInitialSize(3);
        dds.setMaxActive(5);
    }
    public static Connection getConn() throws SQLException {
        Connection conn = dds.getConnection();
        System.out.println("连接对象"+conn);
        return conn;
    }
}
